﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;

namespace CoreLims.Models.CoreLims
{
    public partial class SAMPLE
    {
        public class AnalyteClassificationCompare : IEqualityComparer<SampleAnalyte>
        {
            bool IEqualityComparer<SampleAnalyte>.Equals(SampleAnalyte x, SampleAnalyte y)
            {
                return x.Classification == y.Classification;
            }

            int IEqualityComparer<SampleAnalyte>.GetHashCode(SampleAnalyte obj)
            {
                if (string.IsNullOrEmpty(obj.Classification))
                { return 0; }
                else
                { return obj.Classification.Length; }
            }
        }

        public class SpecFirstGroupCompare : IEqualityComparer<SampleSpec>
        {
            bool IEqualityComparer<SampleSpec>.Equals(SampleSpec x, SampleSpec y)
            {
                return x.FirstGroup == y.FirstGroup;
            }

            int IEqualityComparer<SampleSpec>.GetHashCode(SampleSpec obj)
            {
                if (string.IsNullOrEmpty(obj.FirstGroup))
                { return 0; }
                else
                { return obj.FirstGroup.Length; }
            }
        }

        public class SpecSecondGroupCompare : IEqualityComparer<SampleSpec>
        {
            bool IEqualityComparer<SampleSpec>.Equals(SampleSpec x, SampleSpec y)
            {
                return x.SecondGroup == y.SecondGroup;
            }

            int IEqualityComparer<SampleSpec>.GetHashCode(SampleSpec obj)
            {
                if (string.IsNullOrEmpty(obj.SecondGroup))
                { return 0; }
                else
                { return obj.SecondGroup.Length; }
            }
        }

        public class TestDefinitionTestNameCompare : IEqualityComparer<SampleTestDefinition>
        {
            bool IEqualityComparer<SampleTestDefinition>.Equals(SampleTestDefinition x, SampleTestDefinition y)
            {
                return x.TestName == y.TestName;
            }

            int IEqualityComparer<SampleTestDefinition>.GetHashCode(SampleTestDefinition obj)
            {
                if (string.IsNullOrEmpty(obj.TestName))
                { return 0; }
                else
                { return obj.TestName.Length; }
            }
        }

        public class TestDefinitionFirstGroupCompare : IEqualityComparer<SampleTestDefinition>
        {
            bool IEqualityComparer<SampleTestDefinition>.Equals(SampleTestDefinition x, SampleTestDefinition y)
            {
                return x.FirstGroup == y.FirstGroup;
            }

            int IEqualityComparer<SampleTestDefinition>.GetHashCode(SampleTestDefinition obj)
            {
                if (string.IsNullOrEmpty(obj.FirstGroup))
                { return 0; }
                else
                { return obj.FirstGroup.Length; }
            }
        }

        public class TestDefinitionSecondGroupCompare : IEqualityComparer<SampleTestDefinition>
        {
            bool IEqualityComparer<SampleTestDefinition>.Equals(SampleTestDefinition x, SampleTestDefinition y)
            {
                return x.SecondGroup == y.SecondGroup;
            }

            int IEqualityComparer<SampleTestDefinition>.GetHashCode(SampleTestDefinition obj)
            {
                if (string.IsNullOrEmpty(obj.SecondGroup))
                { return 0;}
                else
                { return obj.SecondGroup.Length; }
            }
        }

        public class SampleDefinitionClassificationCompare : IEqualityComparer<SampleSampleDefinition>
        {
            bool IEqualityComparer<SampleSampleDefinition>.Equals(SampleSampleDefinition x, SampleSampleDefinition y)
            {
                return x.Classification == y.Classification;
            }

            int IEqualityComparer<SampleSampleDefinition>.GetHashCode(SampleSampleDefinition obj)
            {
                if (string.IsNullOrEmpty(obj.Classification))
                { return 0; }
                else
                { return obj.Classification.Length; }
            }
        }

        public class SampleDefinitionGenricClassCompare : IEqualityComparer<SampleSampleDefinition>
        {
            bool IEqualityComparer<SampleSampleDefinition>.Equals(SampleSampleDefinition x, SampleSampleDefinition y)
            {
                return x.GenricClass == y.GenricClass;
            }

            int IEqualityComparer<SampleSampleDefinition>.GetHashCode(SampleSampleDefinition obj)
            {
                if (string.IsNullOrEmpty(obj.GenricClass))
                { return 0; }
                else
                { return obj.GenricClass.Length; }
            }
        }

        public class MethodTypeCompare : IEqualityComparer<SampleMethod>
        {
            bool IEqualityComparer<SampleMethod>.Equals(SampleMethod x, SampleMethod y)
            {
                return x.Type == y.Type;
            }

            int IEqualityComparer<SampleMethod>.GetHashCode(SampleMethod obj)
            {
                if (string.IsNullOrEmpty(obj.Type))
                { return 0; }
                else
                { return obj.Type.Length; }
            }
        }

        public class SampleBatchIdCompare : IEqualityComparer<SampleSample>
        {
            bool IEqualityComparer<SampleSample>.Equals(SampleSample x, SampleSample y)
            {
                return x.BatchId == y.BatchId;
            }

            int IEqualityComparer<SampleSample>.GetHashCode(SampleSample obj)
            {
                if (string.IsNullOrEmpty(obj.BatchId))
                { return 0; }
                else
                { return obj.BatchId.Length; }
            }
        }

        public class ResultAnalyteCompare : IEqualityComparer<SampleResult>
        {
            bool IEqualityComparer<SampleResult>.Equals(SampleResult x, SampleResult y)
            {
                return x.AnalytesCode == y.AnalytesCode;
            }

            int IEqualityComparer<SampleResult>.GetHashCode(SampleResult obj)
            {
                if (string.IsNullOrEmpty(obj.AnalytesCode))
                { return 0; }
                else
                { return obj.AnalytesCode.Length; }
            }
        }

        public class RetentionConfigContainerCompare : IEqualityComparer<RetentionConfig>
        {
            public bool Equals(RetentionConfig x, RetentionConfig y)
            {
                return x.Container == y.Container;
            }

            int IEqualityComparer<RetentionConfig>.GetHashCode(RetentionConfig obj)
            {
                if (string.IsNullOrEmpty(obj.Container))
                { return 0; }
                else
                { return obj.Container.Length; }
            }
        }

        public class RetentionConfigUnitCompare : IEqualityComparer<RetentionConfig>
        {
            public bool Equals(RetentionConfig x, RetentionConfig y)
            {
                return x.Unit == y.Unit;
            }

            int IEqualityComparer<RetentionConfig>.GetHashCode(RetentionConfig obj)
            {
                if (string.IsNullOrEmpty(obj.Unit))
                { return 0; }
                else
                { return obj.Unit.Length; }
            }
        }

        public class RetentionSampleBatchIdCompare : IEqualityComparer<RetentionSample>
        {
            public bool Equals(RetentionSample x, RetentionSample y)
            {
                return x.BatchId == y.BatchId;
            }

            int IEqualityComparer<RetentionSample>.GetHashCode(RetentionSample obj)
            {
                if (string.IsNullOrEmpty(obj.BatchId))
                { return 0; }
                else
                { return obj.BatchId.Length; }
            }
        }

        public class SampleGroupTypeCompare : IEqualityComparer<SampleSampleGroup>
        {
            bool IEqualityComparer<SampleSampleGroup>.Equals(SampleSampleGroup x, SampleSampleGroup y)
            {
                return x.Type == y.Type;
            }

            int IEqualityComparer<SampleSampleGroup>.GetHashCode(SampleSampleGroup obj)
            {
                if (string.IsNullOrEmpty(obj.Type))
                { return 0; }
                else
                { return obj.Type.Length; }
            }
        }
    }
}
